let http = require('https');

function getBase64(url) {
	return new Promise((resolve, reject) => {
		http.get(url, (res) => {
			var chunks = [];
			var size = 0;
			res.on('data', (res) => {
				chunks.push(res);
				size += res.length;
			});
			res.on('end', function(err) {
				var data = Buffer.concat(chunks, size);
				var base64Img = data.toString('base64');
				// console.log(base64Img);
				resolve(base64Img);
			});
		});
	});
}
module.exports = {
	getBase64
}